<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3.经过显示下拉菜单</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-color: #f1f1f1;
        }

        ul {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .myjd {
            position: relative;
            width: 80px;
            height: 20px;
            background-color: #fff;
            margin: 0 auto;
            border-left: 1px solid #ccc;
            border-right: 1px solid #ccc;
            margin-top: 5px;
        }

        p {
            color: #000;
            font-size: 12px;
            margin-left: 8px;
            line-height: 20px;
        }

        span {
            position: absolute;
            top: 6px;
            right: 7px;
            width: 5px;
            height: 5px;
            border-bottom: 1px solid #000;
            border-right: 1px solid #000;
            transform: rotate(45deg);
        }

        ul {
            display: none;
            color: #000;
            font-size: 12px;
            text-align: center;
            background-color: #fff;
            border: 1px solid #ccc;
            border-top: 0;
        }

        ul li {
            padding: 3px;
        }
    </style>
</head>

<body>
    <div class="myjd">
        <p>手机京东</p>
        <span class="down"></span>
        <ul>
            <li>订单</li>
            <li>购物车</li>
            <li>优惠价</li>
            <li>客服</li>
        </ul>
    </div>
    <script>
        var myjd = document.querySelector('.myjd');
        var ul = document.querySelector('ul');
        myjd.onmouseover = function () {
            if (this.onmouseover) {
                ul.style.display = 'block';
            }
        }
        myjd.onmouseout = function () {
            if (this.onmouseout) {
                ul.style.display = 'none';
            }
        }
    </script>
</body>

</html>